<?php

//Load Master Page
require_once('../shared/layout.php');

//Load Custom Control
require_once('../../admin/controls/QEditableLabel.class.php');

class Index extends Layout {

    protected $objEditableArray;
    
    protected function Form_Create() {
        parent::Form_Create();

        $this->strTitle = 'Legal';
        
        $this->CssClass = 'form-mini';
        
        $objContentKeyArray = 
                ContentKey::LoadNameValueArrayByContentPageTypeId(ContentPageType::Legal);
        
        foreach($objContentKeyArray as $key => $objContentKey){
            $this->objEditableArray[$key] = new QEditableLabel($this);
            $this->objEditableArray[$key]->Text = $objContentKey->Value;
            $this->objEditableArray[$key]->ActionParameter = $objContentKey->Id;
            $this->objEditableArray[$key]->ReadOnly = !isset($this->objCurrentUser);
            
            switch ($objContentKey->ContentKeyTypeId) {
                case ContentKeyType::SingleText:
                    $this->objEditableArray[$key]->TextMode = QTextMode::SingleLine;
                    break;
                case ContentKeyType::MultiText:
                    $this->objEditableArray[$key]->TextMode = QTextMode::MultiLine;
                    $this->objEditableArray[$key]->AddCssClass('grid_14');
                    $this->objEditableArray[$key]->Height = '150px';
                    break;
                case ContentKeyType::RichText:
                    $this->objEditableArray[$key]->TextMode = QTextMode::MultiLine;
                    $this->objEditableArray[$key]->AddCssClass('grid_14');
                    $this->objEditableArray[$key]->AddCssClass('wysihtml5');
                    $this->objEditableArray[$key]->Width = '100%';
                    $this->objEditableArray[$key]->Height = '150px';
                    break;
            }
        }
    }
}

Index::Run('Index', __DOCROOT__ . __SUBDIRECTORY__ . '/view/legal/index.tpl.php');
?>